<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="javax.servlet.http.HttpSession" %>
<%@ page import="me.whf.model.Employee" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
	<script type="text/javascript" src="js/jquery-ui.js"></script>
	<link rel="stylesheet" href="css/jquery-ui.css"/>
	<link rel="stylesheet" href="css/bootstrap.css"/>
	<link rel="stylesheet" href="css/navbar.css"/>
	<title>银行管理系统</title>
</head>
<body>
	<div class="navbar">
		<div class="navbar_container">
			<ul>
				<li id="bar_1" class="hover"><a id="navigate_1" onclick="navigate(1)">创建账户</a></li>
				<li id="bar_2"><a id="navigate_2" onclick="navigate(2)">存款</a></li>
				<li id="bar_3"><a id="navigate_3" onclick="navigate(3)">取款</a></li>
				<li id="bar_4"><a id="navigate_4" onclick="navigate(4)">查询</a></li>
				<li id="bar_5"><a id="navigate_5" onclick="navigate(5)">查询流水</a></li>
				<li id="bar_6"><a id="navigate_6" onclick="navigate(6)">转账</a></li>
				<li id="bar_7"><a id="navigate_7" onclick="navigate(7)">更改密码</a></li>
				<li id="bar_8"><a id="navigate_8" onclick="navigate(8)">企业添加操作人</a></li>
				<li id="bar_9"><a id="navigate_9" onclick="navigate(9)">销户</a></li>
				<li id="bar_10"><a id="navigate_10" onclick="navigate(10)">产生报表</a></li>
			</ul>
			<ul>
				<li id="exit" class="exit"><a id="logout">退出</a></li>
			</ul>
		</div>
	</div>
	<% String username = ((Employee)session.getAttribute("employee")).getUsername(); %>
	<center><h3>欢迎：<%= username %></h3></center>
	<div id="panel">
		<form id="panel_1" class="hover">
		<table class="centerTable1">
			<tr><td>用户名：</td><td><input type="text" id="create_username" size="15"></td></tr>
			<tr><td>身份证：</td><td><input type="text" id="create_identity" size="15"></td></tr>
			<tr><td>用户类型：</td><td align="right">
			<select id="create_userType">
		 		<option value="COMMON">普通用户</option>
		 		<option value="VIP">VIP用户</option>
		 		<option value="ENTERPRISE">企业用户</option>
		 	</select></td></tr>
			<tr><td>开户类型：</td><td align="right">
			<select id="create_accountType">
		 		<option value="FIXED">定期</option>
		 		<option value="PERIOD">活期</option>
		 	</select></td></tr>
			<tr><td>余额：</td><td><input type="text" id="create_balance" size="15"></td></tr>
			<tr><td>密码：</td><td><input type="password" id="create_password" size="15"></td></tr>
			<tr><td>密码确认：</td><td><input type="password" id="create_password_confirm" size="15"></td></tr>
			<tr><td>&nbsp;</td><td align="right"><input type="button" class="btn btn-primary" id="create_enter" value="开户"></td></tr>
		</table>
		</form>
		<form id="panel_2" style="display:none">
		<table class="centerTable2">
			<tr><td>用户ID：</td><td><input type="text" id="deposit_accountID" size="15"></td></tr>
			<tr><td>密码：</td><td><input type="password" id="deposit_password" size="15"></td></tr>
			<tr><td>金额：</td><td><input type="text" id="deposit_money" size="15"></td></tr>
			<tr><td>&nbsp;</td><td align="right"><input type="button" id="deposit_enter" class="btn btn-primary" value="存款"></td></tr>
		</table>
		</form>
		<form id="panel_3" style="display:none">
		<table class="centerTable3">
			<tr><td>用户ID：</td><td><input type="text" id="withdraw_accountID" size="15"></td></tr>
			<tr><td>密码：</td><td><input type="password" id="withdraw_password" size="15"></td></tr>
			<tr><td>金额：</td><td><input type="text" id="withdraw_money" size="15"></td></tr>
			<tr><td>&nbsp;</td><td align="right"><input type="button" id="withdraw_enter" class="btn btn-primary" value="取款"></td></tr>
		</table>
		</form>
		<form id="panel_4" style="display:none">
		<table class="centerTable4">
			<tr><td>用户ID：</td><td><input type="text" id="query_accountID" size="15"></td></tr>
			<tr><td>密码：</td><td><input type="password" id="query_password" size="15"></td></tr>
			<tr><td>身份证：</td><td><input type="text" id="query_identity" size="15"></td></tr>
			<tr><td>&nbsp;</td><td align="right"><input type="button" id="query_enter" class="btn btn-primary" value="查询"></td></tr>
		</table>
		</form>
		<form id="panel_5" style="display:none">
		<table class="centerTable5">
			<tr><td>用户ID：</td><td><input type="text" id="querytl_accountID" size="15"></td></tr>
			<tr><td>密码：</td><td><input type="password" id="querytl_password" size="15"></td></tr>
			<tr><td>身份证：</td><td><input type="text" id="querytl_identity" size="15"></td></tr>
			<tr><td>开始日期：</td><td><input type="text" id="querytl_start_date"></td></tr>
			<tr><td>结束日期：</td><td><input type="text" id="querytl_end_date"></td></tr>
			<tr><td>&nbsp;</td><td align="right"><input type="button" id="querytl_enter" class="btn btn-primary" value="查询流水"></td></tr>
		</table>
		</form>
		<form id="panel_6" style="display:none">
		<table class="centerTable6">
			<tr><td>用户ID：</td><td><input type="text" id="transfer_accountID" size="15"></td></tr>
			<tr><td>密码：</td><td><input type="password" id="transfer_password" size="15"></td></tr>
			<tr><td>身份证：</td><td><input type="text" id="transfer_identity" size="15"></td></tr>
			<tr><td>用户名：</td><td><input type="text" id="transfer_username" size="15"></td></tr>
			<tr><td>目标用户ID：</td><td><input type="text" id="transfer_receiver_accountID" size="15"></td></tr>
			<tr><td>目标用户名：</td><td><input type="text" id="transfer_receiver_username" size="15"></td></tr>
			<tr><td>转账金额：</td><td><input type="text" id="transfer_money" size="15"></td></tr>
			<tr><td>&nbsp;</td><td align="right"><input type="button" id="transfer_enter" class="btn btn-primary" value="转账"></td></tr>
		</table>
		</form>
		<form id="panel_7" style="display:none">
		<table class="centerTable7">
			<tr><td>用户ID：</td><td><input type="text" id="change_accountID" size="15"></td></tr>
			<tr><td>旧密码：</td><td><input type="password" id="change_oldPassword" size="15"></td></tr>
			<tr><td>新密码：</td><td><input type="password" id="change_password" size="15"></td></tr>
			<tr><td>密码确认：</td><td><input type="password" id="change_password_confirm" size="15"></td></tr>
			<tr><td>身份证：</td><td><input type="text" id="change_identity" size="15"></td></tr>
			<tr><td>&nbsp;</td><td align="right"><input type="button" id="change_enter" class="btn btn-primary" value="更改密码"></td></tr>
		</table>	
		</form>
		<form id="panel_8" style="display:none">
		<table class="centerTable8">
			<tr><td>用户ID：</td><td><input type="text" id="enterprise_accountID" size="15"></td></tr>
			<tr><td>企业身份证：</td><td><input type="text" id="enterprise_enterpriseID" size="15"></td></tr>
			<tr><td>CEO密码：</td><td><input type="password" id="enterprise_own_password" size="15"></td></tr>
			<tr><td>新增密码：</td><td><input type="password" id="enterprise_operator_password" size="15"></td></tr>
			<tr><td>密码确认：</td><td><input type="password" id="enterprise_operator_password_confirm" size="15"></td></tr>
			<tr><td>&nbsp;</td><td align="right"><input type="button" id="enterprise_enter" class="btn btn-primary" value="添加操作员"></td></tr>
		</table>
		</form>
		<form id="panel_9" style="display:none">
		<table class="centerTable9">
			<tr><td>用户ID：</td><td><input type="text" id="destory_accountID" size="15"></td></tr>
			<tr><td>密码：</td><td><input type="password" id="destory_password" size="15"></td></tr>
			<tr><td>密码确认：</td><td><input type="password" id="destory_password_confirm" size="15"></td></tr>
			<tr><td>身份证：</td><td><input type="text" id="destory_identity" size="15"></td></tr>
			<tr><td>&nbsp;</td><td align="right"><input type="button" id="destory_enter" class="btn btn-primary" value="销户"></td></tr>
		</table>
		</form>
		<form id="panel_10" style="display:none">
		<table class="centerTable10">
			<tr><td>开始日期：</td><td><input type="text" id="createlog_start_date"></td></tr>
			<tr><td>结束日期：</td><td><input type="text" id="createlog_end_date"></td></tr>
			<tr><td>&nbsp;</td><td align="right"><input type="button" id="createlog_enter" class="btn btn-primary" value="产生报表"></td></tr>
		</table>
		</form>
	</div>
</body>


<script type="text/javascript">
	function navigate(index) {
		for (var i = 1; i <= 10; i++) {
			var navigationBar = document.getElementById("bar_" + i);
			var panel = document.getElementById("panel_" + i);
			navigationBar.className = i == index? "hover": "";
			panel.style.display = i == index? "block": "none";
			panel.reset();
		}
		centralization();
	}
	function centralization() {
		var tabletop = 200;
		if (($(window).height() - $(".centerTable" + i).outerHeight()) / 2 < 64)
			tabletop = 64;
		for (var i = 1; i <= 10; i++) {
			$(".centerTable" + i).css({
				position: "absolute",
				left: ($(window).width() - $(".centerTable" + i).outerWidth()) / 2,
				top: tabletop
			});
		}
	}
	$(function() {
		centralization();
		$(window).resize(function (){
			centralization();
		});
		$("#logout").click(function () {
			$.ajax({
				url: "index",
				type: "post",
				dataType: "text",
				data:{
					action: "LOGOUT"
				},
				success: function (data) {
					alert(data);
					location.href = "index.jsp";
				}
			});
		});
		$("#querytl_start_date").datepicker();
		$("#querytl_end_date").datepicker();
		$("#createlog_start_date").datepicker();
		$("#createlog_end_date").datepicker();
		$("#create_enter").click(function () {
			var password = $("#create_password").val();
			var passwordConfirm = $("#create_password_confirm").val();
			var balance = $("#create_balance").val();
			if (password != passwordConfirm) {
				alert("密码输入不一致");
				return;
			}
			if (isNaN(balance)) {
				alert("余额不是数字");
				return;
			}
			$.ajax({
				url: "employee",
				type: "post",
				dataType: "text",
				data: {
					username: $("#create_username").val(),
					identity: $("#create_identity").val(),
					userType: $("#create_userType").val(),
					accountType: $("#create_accountType").val(),
					balance: $("#create_balance").val(),
					password: $("#create_password").val(),
					action: "CREATE_ACCOUNT"
				},
				success: function (data) {
					alert(data);
				}
			});
		});
		$("#deposit_enter").click(function () {
			var balance = $("#deposit_money").val();
			if (isNaN(balance)) {
				alert("金额不是数字");
				return;
			}
			$.ajax({
				url: "employee",
				type: "post",
				dataType: "text",
				data: {
					accountID: $("#deposit_accountID").val(),
					password: $("#deposit_password").val(),
					money: $("#deposit_money").val(),
					action: "DEPOSIT"
				},
				success: function (data) {
					alert(data);
				}
			});
		});
		$("#withdraw_enter").click(function () {
			var balance = $("#withdraw_money").val();
			if (isNaN(balance)) {
				alert("金额不是数字");
				return;
			}
			$.ajax({
				url: "employee",
				type: "post",
				dataType: "text",
				data: {
					accountID: $("#withdraw_accountID").val(),
					password: $("#withdraw_password").val(),
					money: $("#withdraw_money").val(),
					action: "WITHDRAW"
				},
				success: function (data) {
					alert(data);
				}
			});
		});
		$("#query_enter").click(function () {
			$.ajax({
				url: "employee",
				type: "post",
				dataType: "text",
				data: {
					accountID: $("#query_accountID").val(),
					password: $("#query_password").val(),
					identity: $("#query_identity").val(),
					action: "QUERY"
				},
				success: function (data) {
					alert(data);
				}
			});
		});
		$("#querytl_enter").click(function () {
			$.ajax({
				url: "employee",
				type: "post",
				dataType: "text",
				data: {
					accountID: $("#querytl_accountID").val(),
					password: $("#querytl_password").val(),
					identity: $("#querytl_identity").val(),
					startDate: $("#querytl_start_date").val(),
					endDate: $("#querytl_end_date").val(),
					action: "QUERY_TIMELINE"
				},
				success: function (data) {
					alert(data);
				}
			});
		});
		$("#transfer_enter").click(function () {
			var balance = $("#transfer_money").val();
			if (isNaN(balance)) {
				alert("金额不是数字");
				return;
			}
			$.ajax({
				url: "employee",
				type: "post",
				dataType: "text",
				data: {
					accountID: $("#transfer_accountID").val(),
					password: $("#transfer_password").val(),
					identity: $("#transfer_identity").val(),
					username: $("#transfer_username").val(),
					receiverAccountID: $("#transfer_receiver_accountID").val(),
					receiverUsername: $("#transfer_receiver_username").val(),
					money: $("#transfer_money").val(),
					action: "TRANSFER"
				},
				success: function (data) {
					alert(data);
				}
			});
		});
		$("#change_enter").click(function () {
			var password = $("#change_password").val();
			var passwordConfirm = $("#change_password_confirm").val();
			if (password != passwordConfirm) {
				alert("密码输入不一致");
				return;
			}
			$.ajax({
				url: "employee",
				type: "post",
				dataType: "text",
				data: {
					accountID: $("#change_accountID").val(),
					oldPassword: $("#change_oldPassword").val(),
					password: $("#change_password").val(),
					identity: $("#change_identity").val(),
					action: "CHANGE_PASSWORD"
				},
				success: function (data) {
					alert(data);
				}
			});
		});
		$("#enterprise_enter").click(function () {
			var password = $("#enterprise_operator_password").val();
			var passwordConfirm = $("#enterprise_operator_password_confirm").val();
			if (password != passwordConfirm) {
				alert("密码输入不一致");
				return;
			}
			$.ajax({
				url: "employee",
				type: "post",
				dataType: "text",
				data: {
					accountID: $("#enterprise_accountID").val(),
					enterpriseIdentity: $("#enterprise_enterpriseID").val(),
					ownerPassword: $("#enterprise_own_password").val(),
					operatorPassword: $("#enterprise_operator_password").val(),
					action: "ADD_ENTERPRISE_OPERATOR"
				},
				success: function (data) {
					alert(data);
				}
			});
		});
		$("#destory_enter").click(function () {
			var password = $("#destory_password").val();
			var passwordConfirm = $("#destory_password_confirm").val();
			if (password != passwordConfirm) {
				alert("密码输入不一致");
				return;
			}
			$.ajax({
				url: "employee",
				type: "post",
				dataType: "text",
				data: {
					accountID: $("#destory_accountID").val(),
					password: $("#destory_password").val(),
					identity: $("#destory_identity").val(),
					action: "DESTORY"
				},
				success: function (data) {
					alert(data);
				}
			});
		});
		$("#createlog_enter").click(function () {
			$.ajax({
				url: "administrator",
				type: "post",
				dataType: "text",
				data: {
					startDate: $("#createlog_start_date").val(),
					endDate: $("#createlog_end_date").val(),
					action: "LOG"
				},
				success: function (data) {
					alert(data);
				}
			});
		});
	});
	</script>
</html>